package com.UI
{
	import com.*;
	import com.Engine.*;
	import com.Packet.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.external.*;
	import flash.filters.*;
	import flash.geom.*;
	import flash.net.*;
	import flash.system.*;
	import flash.text.*;
	import flash.ui.*;
	import flash.utils.*;
	
	import gs.*;
	import gs.easing.*;
	import gs.events.TweenEvent;
	
	import org.aswing.*;
	import org.aswing.border.*;
	import org.aswing.border.EmptyBorder;
	import org.aswing.colorchooser.*;
	import org.aswing.dnd.*;
	import org.aswing.event.*;
	import org.aswing.ext.*;
	import org.aswing.geom.*;
	import org.aswing.plaf.*;
	import org.aswing.skinbuilder.SkinProgressBarBackground;
	import org.aswing.skinbuilder.SkinProgressBarForeground;
	
	public class FrameTeam extends JFrame
	{
		//members define
		private var panelTop:JPanel;
		private var panel10:JPanel;
		private var btn_tab_team:JToggleButton;
		private var btn_tab_team_soul:JToggleButton;
		private var panelMember_0:PaneTeamMember;
		private var panelMember_1:PaneTeamMember;
		private var panelMember_2:PaneTeamMember;
		private var panelButtons:JPanel;
		private var btn_create:JButton;
		private var btn_leave:JButton;
		private var btn_list:JButton;
		private var panelButtonsSoul:JPanel;
		private var btn_soul_use:JButton;
		private var btn_soul_cancel_use:JButton;
		private var btn_soul_battle_setting:JButton;
		private var btn_soul_list:JButton;
		
		//-----------------------------------
		private var btn_close:JButton;
		public function FrameTeam()
		{
			//component creation
			//super();
			setResizable(false);
			setBackgroundDecorator(null);
			setBorder(new EmptyBorder());
			
			btn_close = new JButton();
			btn_close.setLocation(new IntPoint(198, -5));
			btn_close.setSize(new IntDimension(27, 27));
			btn_close.setPreferredSize(new IntDimension(27, 27));
			getTitleBar().setCloseButton(btn_close);
			getTitleBar().setMinimizeHeight(32);
			
			//component creation
			setSize(new IntDimension(278, 399));
			setPreferredSize(new IntDimension(278, 399));
			var layout0:EmptyLayout = new EmptyLayout();
			getContentPane().setLayout(layout0);
			
			panelTop = new JPanel();
			panelTop.setLocation(new IntPoint(0, 0));
			panelTop.setSize(new IntDimension(278, 33));
			panelTop.setPreferredSize(new IntDimension(278, 33));
			var layout1:FlowLayout = new FlowLayout();
			layout1.setAlignment(AsWingConstants.LEFT);
			layout1.setHgap(20);
			layout1.setVgap(4);
			layout1.setMargin(true);
			panelTop.setLayout(layout1);
			
			panel10 = new JPanel();
			panel10.setLocation(new IntPoint(5, 5));
			panel10.setSize(new IntDimension(134, 25));
			panel10.setPreferredSize(new IntDimension(134, 25));
			var layout2:FlowLayout = new FlowLayout();
			layout2.setAlignment(AsWingConstants.CENTER);
			layout2.setHgap(3);
			layout2.setVgap(0);
			layout2.setMargin(false);
			panel10.setLayout(layout2);
			
			btn_tab_team = new JToggleButton();
			btn_tab_team.setLocation(new IntPoint(5, 5));
			btn_tab_team.setSize(new IntDimension(58, 25));
			btn_tab_team.setPreferredSize(new IntDimension(58, 25));
			btn_tab_team.setText("label");
			
			btn_tab_team_soul = new JToggleButton();
			btn_tab_team_soul.setLocation(new IntPoint(23, 25));
			btn_tab_team_soul.setSize(new IntDimension(73, 25));
			btn_tab_team_soul.setPreferredSize(new IntDimension(73, 25));
			btn_tab_team_soul.setText("label");
			
			panelMember_0 = new PaneTeamMember();
			panelMember_0.setLocation(new IntPoint(11, 44));
			panelMember_0.setSize(new IntDimension(255, 77));
			panelMember_0.setPreferredSize(new IntDimension(255, 77));
			var layout3:EmptyLayout = new EmptyLayout();
			panelMember_0.setLayout(layout3);
			
			panelMember_1 = new PaneTeamMember();
			panelMember_1.setLocation(new IntPoint(11, 149));
			panelMember_1.setSize(new IntDimension(255, 77));
			panelMember_1.setPreferredSize(new IntDimension(255, 77));
			
			panelMember_2 = new PaneTeamMember();
			panelMember_2.setLocation(new IntPoint(11, 252));
			panelMember_2.setSize(new IntDimension(255, 77));
			panelMember_2.setPreferredSize(new IntDimension(255, 77));
			
			panelButtons = new JPanel();
			panelButtons.setLocation(new IntPoint(0, 347));
			panelButtons.setSize(new IntDimension(278, 23));
			panelButtons.setPreferredSize(new IntDimension(278, 23));
			var layout4:FlowLayout = new FlowLayout();
			layout4.setAlignment(AsWingConstants.CENTER);
			layout4.setHgap(10);
			layout4.setVgap(0);
			layout4.setMargin(false);
			panelButtons.setLayout(layout4);
			
			btn_create = new JButton();
			btn_create.setLocation(new IntPoint(52, 2));
			btn_create.setSize(new IntDimension(49, 23));
			btn_create.setPreferredSize(new IntDimension(49, 23));
			btn_create.setText("label");
			
			btn_leave = new JButton();
			btn_leave.setLocation(new IntPoint(113, 2));
			btn_leave.setSize(new IntDimension(49, 23));
			btn_leave.setPreferredSize(new IntDimension(49, 23));
			btn_leave.setText("label");
			
			btn_list = new JButton();
			btn_list.setLocation(new IntPoint(173, 0));
			btn_list.setSize(new IntDimension(49, 23));
			btn_list.setPreferredSize(new IntDimension(49, 23));
			btn_list.setText("label");
			
			panelButtonsSoul = new JPanel();
			panelButtonsSoul.setLocation(new IntPoint(0, 347));
			panelButtonsSoul.setSize(new IntDimension(278, 23));
			panelButtonsSoul.setPreferredSize(new IntDimension(278, 23));
			var layout5:FlowWrapLayout = new FlowWrapLayout();
			layout5.setPreferWidth(200);
			layout5.setAlignment(AsWingConstants.CENTER);
			layout5.setHgap(10);
			layout5.setVgap(0);
			layout5.setMargin(false);
			panelButtonsSoul.setLayout(layout5);
			
			btn_soul_use = new JButton();
			btn_soul_use.setLocation(new IntPoint(35, 0));
			btn_soul_use.setSize(new IntDimension(49, 23));
			btn_soul_use.setPreferredSize(new IntDimension(49, 23));
			btn_soul_use.setText("label");
			
			btn_soul_cancel_use = new JButton();
			btn_soul_cancel_use.setLocation(new IntPoint(35, 0));
			btn_soul_cancel_use.setSize(new IntDimension(72, 23));
			btn_soul_cancel_use.setPreferredSize(new IntDimension(72, 23));
			btn_soul_cancel_use.setText("label");
			
			btn_soul_battle_setting = new JButton();
			btn_soul_battle_setting.setLocation(new IntPoint(144, 0));
			btn_soul_battle_setting.setSize(new IntDimension(72, 23));
			btn_soul_battle_setting.setPreferredSize(new IntDimension(72, 23));
			btn_soul_battle_setting.setText("label");
			
			btn_soul_list = new JButton();
			btn_soul_list.setLocation(new IntPoint(194, 0));
			btn_soul_list.setSize(new IntDimension(49, 23));
			btn_soul_list.setPreferredSize(new IntDimension(49, 23));
			btn_soul_list.setText("label");
			
			//component layoution
			getContentPane().append(panelTop);
			getContentPane().append(panelMember_0);
			getContentPane().append(panelMember_1);
			getContentPane().append(panelMember_2);
			getContentPane().append(panelButtons);
			getContentPane().append(panelButtonsSoul);
			
			panelTop.append(panel10);
			
			panel10.append(btn_tab_team);
			panel10.append(btn_tab_team_soul);
			
			panelButtons.append(btn_create);
			panelButtons.append(btn_leave);
			panelButtons.append(btn_list);
			
			panelButtonsSoul.append(btn_soul_use);
			panelButtonsSoul.append(btn_soul_cancel_use);
			panelButtonsSoul.append(btn_soul_battle_setting);
			panelButtonsSoul.append(btn_soul_list);
			
			//------------------------------
			setImages();
			addEventListener(FrameEvent.FRAME_CLOSING,onFrameClosing);
			addEventListener(AWEvent.HIDDEN,onFrameClosing);
			//setData();
			btn_leave.addActionListener(onBtnLeave);
			btn_create.addActionListener(onBtnCreate);
			btn_soul_use.addActionListener(onBtnSoulUse);
			btn_soul_cancel_use.addActionListener(onBtnSoulCancelUse);
			
			this.setClipMasked(false);
			this.getContentPane().setClipMasked(false);
		}
		private function onFrameClosing(e:Event):void
		{
			if(FrameTeamList.isShowing())
				FrameTeamList.hide();
			
		}
		private function onBtnCreate(e:Event):void
		{
			Client.getInstance().sendPacketLogic(209,[CharInfo.charId]);
		}
		private function onBtnLeave(e:Event):void
		{
			//Client.getInstance().sendPacketLogic(207,[CharInfo.charId]);
			FrameInfo.showMessageDialog("","是否离开队伍?",handleOptionLeave,null,true,null,JOptionPane.YES|JOptionPane.NO);
		}
		private function handleOptionLeave(button:uint):void
		{
			if(button == JOptionPane.YES)
			{
				Client.getInstance().sendPacketLogic(207,[CharInfo.charId]);
			}
		}
		private function onBtnSoulUse(e:Event):void
		{
			Client.getInstance().sendPacketLogic(216,[int(1)]);
		}
		private function onBtnSoulCancelUse(e:Event):void
		{
			FrameInfo.showMessageDialog("","是否取消使用元神队伍?",handleOptionCancelUse,null,true,null,JOptionPane.YES|JOptionPane.NO);
		}
		private function handleOptionCancelUse(button:uint):void
		{
			if(button == JOptionPane.YES)
			{
				Client.getInstance().sendPacketLogic(216,[int(0)]);
			}
		}
		private function onBtnBattleSetting(e:Event):void
		{
			if(FrameTeamList.isShowing())
				FrameTeamList.hide();
			FrameBattleSetting.show(_frame,FrameBattleSetting.BATTLE_SETTING_TYPE_TEAMMATE);
		}
		private var _mallItems:Array = new Array();
		public function setImages():void
		{
			var img_char_background:DisplayObject = Client.getUIElement("img_team_bg") as DisplayObject
			setBackgroundDecorator(new AssetBackground(img_char_background));
			setSizeWH(img_char_background.width,img_char_background.height);
			setLocationXY((Engine.W - width)/2,(Engine.H - height)/2);
			btn_tab_team.setSelected(true);
			panelButtons.setVisible(true);
			panelButtonsSoul.setVisible(false);
			
			
			btn_tab_team.wrapSimpleButton(Client.getUIElement("btn_team_tab_team") as SimpleButton);
			btn_tab_team_soul.wrapSimpleButton(Client.getUIElement("btn_team_tab_team_soul") as SimpleButton);
			btn_tab_team.setText("");
			btn_tab_team_soul.setText("");
			
			var group:ButtonGroup = new ButtonGroup();
			group.appendAll(btn_tab_team,btn_tab_team_soul);
			btn_tab_team.addActionListener(onBtnTabTeam);
			btn_tab_team_soul.addActionListener(onBtnTabTeamSoul);
			btn_list.addActionListener(onBtnList);
			btn_soul_list.addActionListener(onBtnList);
			btn_soul_battle_setting.addActionListener(onBtnBattleSetting);
			
			btn_create.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
			btn_leave.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
			btn_list.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
			btn_create.setText("创建");
			btn_leave.setText("离队");
			btn_list.setText("列表");
			
			btn_soul_use.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
			btn_soul_use.setText("使用");
			btn_soul_cancel_use.wrapSimpleButton(Client.getUIElement("btn_4") as SimpleButton);
			btn_soul_cancel_use.setText("取消使用");
			btn_soul_battle_setting.wrapSimpleButton(Client.getUIElement("btn_4") as SimpleButton);
			btn_soul_battle_setting.setText("战斗设置");
			btn_soul_list.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
			btn_soul_list.setText("列表");
			
			var filter:GlowFilter;
			var font:ASFont = new ASFont("宋体", 13, false, false, false, false);
			filter = new GlowFilter(0x000000, 1, 2, 2, 5);
			btn_create.setFont(font);
			btn_create.setTextFilters(new Array(filter));
			btn_leave.setFont(font);
			btn_leave.setTextFilters(new Array(filter));
			btn_list.setFont(font);
			btn_list.setTextFilters(new Array(filter));
			btn_soul_use.setFont(font);
			btn_soul_use.setTextFilters(new Array(filter));
			btn_soul_cancel_use.setFont(font);
			btn_soul_cancel_use.setTextFilters(new Array(filter));
			btn_soul_battle_setting.setFont(font);
			btn_soul_battle_setting.setTextFilters(new Array(filter));
			btn_soul_list.setFont(font);
			btn_soul_list.setTextFilters(new Array(filter));

			
			btn_close.wrapSimpleButton(Client.getUIElement("btn_close") as SimpleButton);
			
			_mallItems.push(panelMember_0);
			_mallItems.push(panelMember_1);
			_mallItems.push(panelMember_2);
		}
		
		protected function onBtnTabTeam(e:Event):void
		{
			panelButtons.setVisible(true);
			panelButtonsSoul.setVisible(false);
			setData();
			if(FrameTeamList.isShowing())
				FrameTeamList.update()
		}
		protected function onBtnTabTeamSoul(e:Event):void
		{
			panelButtons.setVisible(false);
			panelButtonsSoul.setVisible(true);
			setData();
			if(FrameTeamList.isShowing())
				FrameTeamList.update()
		}
		
		protected function onBtnList(e:Event):void
		{
			if(FrameBattleSetting.isShowing())
				FrameBattleSetting.hide();
			FrameTeamList.show();
		}
		
		public static function isShowTeamSoul():Boolean
		{
			return _frame != null && _frame.btn_tab_team_soul.isSelected();
		}
		public static function isUseTeamSoul():Boolean
		{
			return CharInfo.m_nUseTeamSoul == 1;
		}
		public static var _frame:FrameTeam = null;
		public static function show():void
		{
			
			if(isShowing())
			{
				hide()
				return;
			}
			if(_frame == null)
			{
				_frame = new FrameTeam();
				PanelMainHelp.getInstance().addChild(_frame);
			}
			_frame.show();
			var useTeamSoul:Boolean = isUseTeamSoul();
			_frame.btn_tab_team.setSelected(!useTeamSoul);
			_frame.btn_tab_team_soul.setSelected(useTeamSoul);
			if(!useTeamSoul)
				_frame.onBtnTabTeam(null);
			else 
				_frame.onBtnTabTeamSoul(null);
			//_frame.setData();
			PanelMainHelp.getInstance().bringToTop(_frame);
			//if(FrameTeamMain.isShowing())
			//	FrameTeamMain._frame.update();
			
		}
		public static function hide():void
		{
			if(isShowing())_frame.hide();
		}
		public static function isShowing():Boolean
		{
			return(_frame != null&& _frame.isShowing());
		}
		
		public static function isInTeam():Boolean
		{
			if(CharInfo.objSelf == null)
				return false;
			if(CharInfo.objSelf.teamLeader == null || CharInfo.objSelf.teamLeader.m_nCharId == null)
				return false;

			var objLeader:ObjectChar = SceneMain.getInstance().getObjectByCharId(CharInfo.objSelf.teamLeader.m_nCharId) as ObjectChar;
			
			if(objLeader == null)return false;
			
			for each(var item:Object in objLeader.teamMembers)
			{
				if(item.m_nCharId == CharInfo.charId)
				{
					return true;
				}	
			}
			
			return false;
		}
		
		public static function isTeamLeader():Boolean
		{
			if(CharInfo.objSelf == null || !isInTeam())
			{
				return false;
			}
			
			return CharInfo.objSelf.teamLeader.m_nCharId == CharInfo.charId;
		}
		
		public function setData():void
		{
			btn_leave.setVisible(FrameTeam.isInTeam());
			btn_create.setVisible(!FrameTeam.isInTeam());
			
			btn_soul_use.setVisible(CharInfo.m_nUseTeamSoul == 0);
			btn_soul_cancel_use.setVisible(CharInfo.m_nUseTeamSoul == 1);
			for each(var obj:Object in _mallItems)
			{
				obj.item = null;
			}
			_frame.filters = null;
			//_frame.alpha = 1.0;

			var nIndex:int = 0;
			var nCount:int = 0;
			var array:Array = null;
			if(btn_tab_team.isSelected())
			{
				if(!FrameTeam.isInTeam())
					return;
				var objLeader:ObjectChar = SceneMain.getInstance().getObjectByCharId(CharInfo.objSelf.teamLeader.m_nCharId) as ObjectChar;
				if(objLeader == null)
				{
					trace("objLeader == null");
					return;
				}
				array = objLeader.teamMembers;
			}
			else
			{
				array = CharInfo.m_arTeamSoulMembers;//CharInfo.objSelf.teamSoulMembers;
				//var matrix : Array = [0.3086, 0.6094, 0.0820, 0, 0, 0.3086, 0.6094, 0.0820, 0, 0, 0.3086, 0.6094, 0.0820, 0, 0, 0, 0, 0, 1, 0];
				//_frame.filters = [new ColorMatrixFilter(matrix)];
			}
			for each(var item:Object in array)
			{
				_mallItems[nIndex++].item = item;
				if(nIndex >= 3)
					break;
			}
		}

		static public function phTeamInvite_200(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phTeamInvite_200", msg);
			var nIndex:uint = 0;
			nCharIdTeamInvite = msg[nIndex++];
			strNameTeamInvite = msg[nIndex++];
			
			FrameInfo.showMessageDialog("","是否同意["+strNameTeamInvite+"]的组队邀请?",handleOptionTeamInvite,null,true,null,JOptionPane.YES|JOptionPane.NO);
		}
		
		static private var nCharIdTeamInvite:uint;
		static private var strNameTeamInvite:String;
		static public function handleOptionTeamInvite(button:uint):void
		{
			Client.getInstance().sendPacketLogic(201,[button == FrameInfo.YES?0:1,nCharIdTeamInvite,strNameTeamInvite]);
		}
		
		static public function phTeamInviteAnswer_201(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phTeamInviteAnswer_201", msg);
			var nIndex:uint = 0;
			var nResult:uint = msg[nIndex++];
			var m_nCharId:uint = msg[nIndex++];
			var m_szCharName:String = msg[nIndex++];

			if(nResult == 1)
				PanelMain.showInfoTimeLimit("["+m_szCharName+"]拒绝了你的组队邀请!");
			else
				PanelMain.showInfoTimeLimit("["+m_szCharName+"]同意了你的组队邀请!",Const.INFO_TYPE_SUCCESS);
		}
		

		static public function phTeamSoulInvite_212(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phTeamSoulInvite_212", msg);
			var nIndex:uint = 0;
			nCharIdTeamSoulInvite = msg[nIndex++];
			strNameTeamSoulInvite = msg[nIndex++];
			
			FrameInfo.showMessageDialog("","是否同意["+strNameTeamSoulInvite+"]的元神组队邀请?",handleOptionTeamSoulInvite,null,true,null,JOptionPane.YES|JOptionPane.NO);
		}
		
		static private var nCharIdTeamSoulInvite:uint;
		static private var strNameTeamSoulInvite:String;
		static public function handleOptionTeamSoulInvite(button:uint):void
		{
			Client.getInstance().sendPacketLogic(213,[button == FrameInfo.YES?0:1,nCharIdTeamSoulInvite,strNameTeamSoulInvite]);
		}
		
		static public function phTeam_202(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phTeam_202", msg);
			var nIndex:uint = 0;
			var m_nCharId:uint = msg[nIndex++];
			
			var objLeader:ObjectChar = SceneMain.getInstance().getObjectByCharId(m_nCharId) as ObjectChar;
			if(objLeader == null)
			{
				trace("objLeader == null");
				return;
			}
			objLeader.teamLeader = null;
			objLeader.follow(null);
			var nCount:uint = msg[nIndex++];
			var array:Array = objLeader.teamMembers;
			
			for each(var mem:Object in objLeader.teamMembers)
			{
				var objMemberChar:ObjectChar = SceneMain.getInstance().getObjectByCharId(mem.m_nCharId) as ObjectChar;
				if(objMemberChar != null)
				{
					objMemberChar.teamLeader = null;
					objMemberChar.follow(null);
				}
			}

			array.splice(0,array.length);
			
			var isSelfTeam:Boolean = false;
			var objMember:ObjectChar = null;
			objLeader.teamLeader = null
			for(var i:int = 0; i < nCount; i++)
			{
				var obj:Object = new Object();
				array[i] = obj;
				obj.m_nCharId = msg[nIndex++];
				obj.m_szCharName = msg[nIndex++];
				obj.m_nLevel = msg[nIndex++];
				obj.m_nRace = msg[nIndex++];
				obj.m_nGender = msg[nIndex++];
				/*var nEquips:uint = msg[nIndex++];
				obj.arCharEquips = [];
				for(var j:int = 0; j < nEquips; j++)
				{
					obj.arCharEquips[j] =  msg[nIndex++];
				}
				obj.m_nImageId = msg[nIndex++];*/

				if(objLeader.teamLeader == null)
					objLeader.teamLeader = obj;
				objMember = SceneMain.getInstance().getObjectByCharId(obj.m_nCharId) as ObjectChar;
				if(objMember != null)
				{
					objMember.teamLeader = objLeader.teamLeader;
					objMember.follow(null);
					if(objMember != objLeader)
						objMember.follow(objLeader);
				}
				if(obj.m_nCharId == CharInfo.charId)
					isSelfTeam = true;
			}
			objLeader.teamLeader = objLeader.teamMembers[0];
			if(isSelfTeam)
			{
				if(isShowing())
					_frame.setData();
				
				FrameTeamMain.show();
				FrameTeamMain._frame.update();
				if(FrameTeamList.isShowing())
					FrameTeamList.update();
			}
			updateTeamLeader(objLeader as ObjectCharPlayer);
		}
		static public function phTeamDestroy_203(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phTeamDestroy_203", msg);
			var nIndex:uint = 0;
			var m_nCharId:uint = msg[nIndex++];
			
			var objLeader:ObjectChar = SceneMain.getInstance().getObjectByCharId(m_nCharId) as ObjectChar;
			if(objLeader == null)
			{
				trace("objLeader == null");
				return;
			}
			objLeader.follow(null);
			objLeader.teamLeader.m_nCharId = 0;
			objLeader.teamLeader.m_szCharName = "";
			objLeader.teamLeader.m_nLevel = 0;
			
			var isSelfTeam:Boolean = false;
			for each(var member:Object in objLeader.teamMembers)
			{
				if(member.m_nCharId == CharInfo.charId)
					isSelfTeam = true;
				var objMember:ObjectChar = SceneMain.getInstance().getObjectByCharId(member.m_nCharId) as ObjectChar;
				if(objMember != null)
				{
					objMember.follow(null);
					objMember.teamLeader = new Object();
				}
			}
			objLeader.teamMembers.splice(0,objLeader.teamMembers.length);
			if(isSelfTeam)
			{
				PanelMain.showInfoTimeLimit("队伍已经解散!");
				if(isShowing())
					_frame.setData();
				FrameTeamMain.hide();
				FrameTeamMain._frame.update();
				if(FrameTeamList.isShowing())
					FrameTeamList.update();
			}
			updateTeamLeader(objLeader as ObjectCharPlayer);
		}
		
		static public function phTeamLeave_207(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phTeamLeave_207", msg);
			var nIndex:uint = 0;
			var nKickedCharId:uint = msg[nIndex++];
			
			var objMember:ObjectCharPlayer = SceneMain.getInstance().getObjectByCharId(nKickedCharId) as ObjectCharPlayer;
			if(objMember == null)
			{
				return;
			}
			
			if(objMember.isTeamLeader())
			{
				
				var objLeader:ObjectChar = objMember
				objLeader.follow(null);
				objLeader.teamLeader = new Object();
				
				var isSelfTeam:Boolean = false;
				for each(var member:Object in objLeader.teamMembers)
				{
					if(member.m_nCharId == CharInfo.charId)
						isSelfTeam = true;
					var mem:ObjectChar = SceneMain.getInstance().getObjectByCharId(member.m_nCharId) as ObjectChar;
					if(mem != null)
					{
						mem.follow(null);
						mem.teamLeader = new Object();
					}
				}
				objLeader.teamMembers.splice(0,objLeader.teamMembers.length);
			}
			
			objMember.follow(null);
			objMember.teamLeader = new Object();
			
			if(nKickedCharId == CharInfo.charId)
			{
				if(isShowing())
					_frame.setData();
				FrameTeamMain.hide();
				FrameTeamMain._frame.update();
				if(FrameTeamList.isShowing())
					FrameTeamList.update();
			}
		}
		
		static public function phTeamKick_208(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phTeamKick_208", msg);
			var nIndex:uint = 0;
			var m_nCharId:uint = msg[nIndex++];
			
			var objLeader:ObjectChar = SceneMain.getInstance().getObjectByCharId(m_nCharId) as ObjectChar;
			if(objLeader == null)
			{
				trace("objLeader == null");
				return;
			}
			
			var nKickedCharId:uint = msg[nIndex++];
			
			for each(var member:Object in objLeader.teamMembers)
			{
				if(member.m_nCharId == nKickedCharId)
				{
					var objMember:ObjectChar = SceneMain.getInstance().getObjectByCharId(member.m_nCharId) as ObjectChar;
					if(objMember != null)
					{
						objMember.follow(null);
						objMember.teamLeader = new Object();
					}
				}
			}
			var index:int = objLeader.teamMembers.indexOf(nKickedCharId);
			if(index != -1)
				objLeader.teamMembers.splice(index,1);
			//objLeader.teamMembers.splice(0,objLeader.teamMembers.length);
			if(nKickedCharId == CharInfo.charId)
			{
				if(isShowing())
					_frame.setData();
				FrameTeamMain.hide();
				FrameTeamMain._frame.update();
				if(FrameTeamList.isShowing())
					FrameTeamList.update();
			}
		}
		
		static public function phTeamWaitingList_210(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phTeamWaitingList_210", msg);
			var nIndex:uint = 0;
			var nCount:uint = msg[nIndex++];
			var array:Array = FrameTeamList._arWait;
			array.splice(0,array.length);
			for(var i:int = 0; i < nCount; i++)
			{
				var obj:Object = new Object();
				array[i] = obj;
				obj.m_nCharId = msg[nIndex++];
				obj.m_szCharName = msg[nIndex++];
				obj.m_nRace = msg[nIndex++];
				obj.m_nGender = msg[nIndex++];
				obj.m_nLevel = msg[nIndex++];
			}
			if(FrameTeamList.isShowing())
				FrameTeamList.update();
		}
		
		static public function phTeamSoul_214(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phTeamSoul_214", msg);
			var nIndex:uint = 0;
			var m_nCharId:uint = msg[nIndex++];
			var nUseTeamSoul:int = msg[nIndex++];
			//var bSendToSelf:int = msg[nIndex++];
			
			var objLeader:ObjectCharPlayer = SceneMain.getInstance().getObjectByCharId(m_nCharId);
			if(objLeader == null)
			{
				trace("objLeader == null");
				return;
			}
			objLeader.teamSoulLeader = null;
			objLeader.follow(null);
			objLeader.isUseTeamSoul = nUseTeamSoul;
			if(m_nCharId == CharInfo.charId)
				CharInfo.m_nUseTeamSoul = nUseTeamSoul;
			var nCount:uint = msg[nIndex++];
			var array:Array = objLeader.teamSoulMembers;
			
			for each(var mem:Object in objLeader.teamSoulMembers)
			{
				var objMemberChar:ObjectCharSoul = SceneMain.getInstance().getObjectBySoulId(mem.m_nCharId,m_nCharId);
				if(objMemberChar != null && objMemberChar.teamSoulLeader != null && objMemberChar.teamSoulLeader.m_nCharId == m_nCharId)
				{
					objMemberChar.teamSoulLeader = null;
					objMemberChar.follow(null);
					if(nUseTeamSoul == 0)
						SceneMain.getInstance().removeObject(objMemberChar);
				}
			}
			
			array.splice(0,array.length);
			
			var isSelfTeam:Boolean = false;
			var objMember:ObjectChar = null;
			objLeader.teamSoulLeader = null
			for(var i:int = 0; i < nCount; i++)
			{
				var obj:Object = new Object();
				array[i] = obj;
				obj.m_nCharId = msg[nIndex++];
				obj.m_szCharName = msg[nIndex++];
				obj.m_nRace = msg[nIndex++];
				obj.m_nGender = msg[nIndex++];
				obj.m_nLevel = msg[nIndex++];
				var nEquips:uint = msg[nIndex++];
				if(obj.arCharEquips == null)
					obj.arCharEquips = new Array;
				for(var j:int = 0; j < nEquips; j++)
				{
					obj.arCharEquips[j] =  msg[nIndex++];
				}
				obj.m_nImageId =  msg[nIndex++];
				
				obj.m_szCharName = obj.m_szCharName;
				obj.m_nLevel = obj.m_nLevel;
				
				if(obj.m_nCharId == CharInfo.charId)
					isSelfTeam = true;
				
				if(objLeader.teamSoulLeader == null)
					objLeader.teamSoulLeader = obj;
				
				var objSoul:ObjectCharSoul = null;
				if(nUseTeamSoul == 0)
				{
					objSoul = SceneMain.getInstance().getObjectBySoulId(obj.m_nCharId,m_nCharId);
					if(objSoul == null || objSoul.teamSoulLeader == null || objSoul.teamSoulLeader.m_nCharId != m_nCharId)
					{
						continue;
					}
					objSoul.follow(null);
					objMemberChar.teamSoulLeader = null;
					SceneMain.getInstance().removeObject(objSoul);
				}
				else
				{
					if(obj.m_nCharId == objLeader.charId)
						continue;
					objSoul = SceneMain.getInstance().getObjectBySoulId(obj.m_nCharId,m_nCharId);
					if(objSoul == null)
					{
						var arrayEquips:Array = new Array();
						if(obj.m_nImageId != 0)
						{
							arrayEquips.push(Engine.assetMapMonsterPath + "npc_"+ obj.m_nImageId + '.swf');
						}
						else
						{
							arrayEquips.push(Engine.assetCharPath + "char_"+ obj.m_nRace + obj.m_nGender + obj.arCharEquips[0] + '.swf');
							arrayEquips.push(Engine.assetCharPath + "char_"+ obj.m_nRace + obj.m_nGender + obj.arCharEquips[1] + '.swf');
							arrayEquips.push(Engine.assetCharPath + "char_"+ obj.m_nRace + obj.m_nGender + obj.arCharEquips[2] + '.swf');
							arrayEquips.push(Engine.assetCharPath + "char_"+ obj.m_nRace + obj.m_nGender + obj.arCharEquips[3] + '.swf');
							arrayEquips.push(Engine.assetCharPath + "char_"+ obj.m_nRace + obj.m_nGender + obj.arCharEquips[4] + '.swf');
							arrayEquips.push(Engine.assetCharPath + "char_"+ obj.m_nRace + obj.m_nGender + obj.arCharEquips[5] + '.swf');
						}
						objSoul = SceneMain.getInstance().createCharSoul(arrayEquips,"char_"+ obj.m_nCharId + '.swf',obj.m_szCharName,new Point(objLeader.getPos().x,objLeader.getPos().y),obj.m_nGender);
					}
					
					objSoul.ownerId = m_nCharId;
					objSoul.soulId = obj.m_nCharId;
					objSoul.follow(objLeader);
					objSoul.setName(obj.m_szCharName);
					objSoul.setTitle(obj.m_szCharName+"的元神");
					
					objSoul.teamSoulLeader = objLeader.teamSoulLeader;
					objSoul.follow(null);
					if(obj.m_nCharId != objLeader.charId)
						objSoul.follow(objLeader);
				}
			}
			objLeader.teamSoulLeader = objLeader.teamSoulMembers[0];
			objLeader.teamSoulLeader.isSoul = false;
			updateTeamLeader(objLeader);
			
			if(isSelfTeam)
			{
				if(isShowing())
					_frame.setData();
				
				FrameTeamMain.show();
				FrameTeamMain._frame.update();
				if(FrameTeamList.isShowing())
					FrameTeamList.update();
			}

		}
		static public function hasTeamMember(m_nCharId:int):Boolean
		{
			if(!isInTeam())
				return false;
			
			if(!isTeamLeader())
				return true;
			
			for each(var obj:Object in CharInfo.objSelf.teamMembers)
			{
				if(obj.m_nCharId == m_nCharId)
					return true;
			}
			return false;
		}
		static public function hasTeamSoulMember(m_nCharId:int):Boolean
		{
			for each(var obj:Object in CharInfo.m_arTeamSoulMembers)
			{
				if(obj.m_nCharId == m_nCharId)
					return true;
			}
			return false;
		}
		
		static public function phJoinTeamSoul_218(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phJoinTeamSoul_218", msg);
			var nIndex:uint = 0;
			var nCount:uint = msg[nIndex++];
			var array:Array = CharInfo.m_arJoinTeamSoul;
			array.splice(0,array.length);
			for(var i:int = 0; i < nCount; i++)
			{
				var obj:Object = new Object();
				array[i] = obj;
				obj.m_nCharId = msg[nIndex++];
				obj.m_szCharName = msg[nIndex++];
				obj.m_nLevel = msg[nIndex++];
				obj.m_nRace = msg[nIndex++];
				obj.m_nGender = msg[nIndex++];
			}
			
			if(FrameTeamList.isShowing())
				FrameTeamList.update();
		}
		static public function phTeamSoul_217(e:PacketEvent):void
		{
			var msg:Array = e.data as Array;
			trace("phTeamSoul_217", msg);
			var nIndex:uint = 0;
			var m_nCharId:uint = msg[nIndex++];
			var nUseTeamSoul:int = msg[nIndex++];
			

			CharInfo.m_nUseTeamSoul = nUseTeamSoul;
			
			var nCount:uint = msg[nIndex++];
			var array:Array = CharInfo.m_arTeamSoulMembers;

			array.splice(0,array.length);
			
			for(var i:int = 0; i < nCount; i++)
			{
				var obj:Object = new Object();
				array[i] = obj;
				obj.m_nCharId = msg[nIndex++];
				obj.m_szCharName = msg[nIndex++];
				obj.m_nRace = msg[nIndex++];
				obj.m_nGender = msg[nIndex++];
				obj.m_nLevel = msg[nIndex++];
				var nEquips:uint = msg[nIndex++];
				if(obj.arCharEquips == null)
					obj.arCharEquips = new Array;
				for(var j:int = 0; j < nEquips; j++)
				{
					obj.arCharEquips[j] =  msg[nIndex++];
				}
				obj.m_nImageId =  msg[nIndex++];
				
				obj.m_szCharName = obj.m_szCharName;
				obj.m_nLevel = obj.m_nLevel;

				var objSkill:Object = null;
				obj.m_arSkills = [];
				var nSkills:uint = msg[nIndex++];
				for(j = 0; j < nSkills; j++)
				{
					objSkill = new Object();
					objSkill.csv_id = msg[nIndex++];
					objSkill.m_nLevel = msg[nIndex++];
					obj.m_arSkills[j] = objSkill;
				}
				
				obj.m_nBattleMode = msg[nIndex++];
				obj.m_arAutoBattleSkills = [];
				for(var k:int = 0; k < 6; k++)
					obj.m_arAutoBattleSkills[k] = msg[nIndex++];
				obj.m_arAutoBattleSkillsSoul = [];
				for(k = 0; k < 6; k++)
					obj.m_arAutoBattleSkillsSoul[k] = msg[nIndex++];
				
				obj.objPartner = {};
				obj.objPartner.m_nSoulType = msg[nIndex++];
				if(obj.objPartner.m_nSoulType != Const.SOUL_TYPE_NULL)
				{
					obj.objPartner.m_arSkills = [];
					nSkills = msg[nIndex++];
					for(j = 0; j < nSkills; j++)
					{
						objSkill = new Object();
						objSkill.csv_id = msg[nIndex++];
						objSkill.m_nLevel = msg[nIndex++];
						obj.objPartner.m_arSkills[j] = objSkill;
					}
					
					obj.objPartner.m_nBattleMode = msg[nIndex++];
					obj.objPartner.m_arAutoBattleSkills = [];
					for(k = 0; k < 6; k++)
						obj.objPartner.m_arAutoBattleSkills[k] = msg[nIndex++];
					obj.objPartner.m_arAutoBattleSkillsSoul = [];
					for(k = 0; k < 6; k++)
						obj.objPartner.m_arAutoBattleSkillsSoul[k] = msg[nIndex++];
				}
	
			}
			
			if(FrameBattleSetting.isShowing())
				FrameBattleSetting._frame.update();
			

			if(isShowing())
				_frame.setData();
			FrameTeamMain.show();
			FrameTeamMain._frame.update();
			if(FrameTeamList.isShowing())
				FrameTeamList.update();
			if(FrameBattleSetting.isShowing())
				FrameBattleSetting._frame.update();
		}
		
		static public function updateTeamLeader(objLeader:ObjectCharPlayer):void
		{
			
			if(objLeader.isUseTeamSoul == 1 || objLeader.isTeamLeader())
			{
				if(!objLeader.hasEffect(SceneMain._effect_team_leader))
				{
					var name:String = null;
					name = "mc_effect_" + SceneMain._effect_team_leader;
					
					var mc_effect:MovieClip = Client.getEffectElement(name) as MovieClip;
					objLeader.addEffect(SceneMain._effect_team_leader,mc_effect,true,false);
				}
			}
			else
			{
				objLeader.removeEffect(SceneMain._effect_team_leader);
			}
			//objLeader.isSoul = (objLeader.isUseTeamSoul == 1);
		}
	}
}

import com.*;
import com.Engine.*;
import com.Packet.*;
import com.UI.*;

import flash.display.*;
import flash.events.*;
import flash.external.*;
import flash.filters.*;
import flash.geom.*;
import flash.net.*;
import flash.system.*;
import flash.text.*;
import flash.ui.*;
import flash.utils.*;

import gs.*;
import gs.easing.*;
import gs.events.TweenEvent;

//import mx.containers.Panel;

import org.aswing.*;
import org.aswing.border.*;
import org.aswing.border.EmptyBorder;
import org.aswing.colorchooser.*;
import org.aswing.dnd.*;
import org.aswing.event.*;
import org.aswing.ext.*;
import org.aswing.geom.*;
import org.aswing.tree.AbstractLayoutCache;
/**
 * MyPaneTeamMember
 */
class PaneTeamMember extends JPanel{
	
	//members define
	private var panelHead:JPanel;
	private var labelName:JLabelButton;
	private var labelRace:JLabel;
	private var labelGender:JLabel;
	private var btn_promote:JButton;
	private var btn_kick:JButton;
	private var btn_chat:JButton;
	
	/**
	 * MyPaneTeamMember Constructor
	 */
	private var _item:Object = null;
	public function PaneTeamMember(){
		//component creation
		setSize(new IntDimension(255, 77));
		setPreferredSize(new IntDimension(255, 77));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		panelHead = new JPanel();
		panelHead.setLocation(new IntPoint(5, 4));
		panelHead.setSize(new IntDimension(69, 69));
		panelHead.setPreferredSize(new IntDimension(69, 69));
		
		labelName = new JLabelButton();
		labelName.setLocation(new IntPoint(76, 6));
		labelName.setSize(new IntDimension(99, 16));
		labelName.setPreferredSize(new IntDimension(99, 16));
		labelName.setText("label");
		
		labelRace = new JLabel();
		labelRace.setLocation(new IntPoint(76, 31));
		labelRace.setSize(new IntDimension(99, 16));
		labelRace.setPreferredSize(new IntDimension(99, 16));
		labelRace.setText("label");
		
		labelGender = new JLabel();
		labelGender.setLocation(new IntPoint(76, 56));
		labelGender.setSize(new IntDimension(99, 16));
		labelGender.setPreferredSize(new IntDimension(99, 16));
		labelGender.setText("label");
		
		btn_promote = new JButton();
		btn_promote.setLocation(new IntPoint(180, 3));
		btn_promote.setSize(new IntDimension(65, 24));
		btn_promote.setPreferredSize(new IntDimension(65, 24));
		btn_promote.setText("label");
		
		btn_kick = new JButton();
		btn_kick.setLocation(new IntPoint(186, 29));
		btn_kick.setSize(new IntDimension(52, 24));
		btn_kick.setPreferredSize(new IntDimension(52, 24));
		btn_kick.setText("label");
		
		btn_chat = new JButton();
		btn_chat.setLocation(new IntPoint(186, 55));
		btn_chat.setSize(new IntDimension(52, 24));
		btn_chat.setPreferredSize(new IntDimension(52, 24));
		btn_chat.setText("label");
		
		//component layoution
		append(panelHead);
		append(labelName);
		append(labelRace);
		append(labelGender);
		append(btn_promote);
		append(btn_kick);
		append(btn_chat);
		
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 12, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 10);
		//labelName.setFont(font);
		//labelName.setForeground(ASColor.WHITE);
		//labelName.setTextFilters(new Array(filter));
		labelRace.setFont(font);
		labelRace.setForeground(ASColor.WHITE);
		labelRace.setTextFilters(new Array(filter));
		labelGender.setFont(font);
		labelGender.setForeground(ASColor.WHITE);
		labelGender.setTextFilters(new Array(filter));
		
		panelHead.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_head") as DisplayObject));
		btn_promote.wrapSimpleButton(Client.getUIElement("btn_team_promote") as SimpleButton);
		btn_promote.setText("");
		btn_kick.wrapSimpleButton(Client.getUIElement("btn_team_kick") as SimpleButton);
		btn_kick.setText("");
		btn_chat.wrapSimpleButton(Client.getUIElement("btn_team_chat") as SimpleButton);
		btn_chat.setText("");
		
		btn_promote.addActionListener(onBtnPromote);
		btn_kick.addActionListener(onBtnKick);
		btn_chat.addActionListener(onBtnChat);
		
		labelName.setForeground(ASColor.WHITE);
		labelName.setFont(new ASFont("宋体", 12, false, false, true, false));
		labelName.setTextFilters( new Array(filter));
		labelName.addActionListener(onBtnName);
		this.setClipMasked(false);
	}
	
	private function onBtnPromote(e:Event):void
	{
		Client.getInstance().sendPacketLogic(204,[CharInfo.charId,int(_item.m_nCharId)]);
	}
	private function onBtnKick(e:Event):void
	{
		//if(FrameTeam.isShowTeamSoul())
		//	Client.getInstance().sendPacketLogic(215,[CharInfo.charId,int(_item.m_nCharId)]);
		//else
		//Client.getInstance().sendPacketLogic(208,[CharInfo.charId,int(_item.m_nCharId)]);
		if(FrameTeam.isShowTeamSoul())
			FrameInfo.showMessageDialog("","是否将  "+_item.m_szCharName+" 踢出元神队伍?",handleOptionKick,null,true,null,JOptionPane.YES|JOptionPane.NO);
		else
			FrameInfo.showMessageDialog("","是否将  "+_item.m_szCharName+" 踢出队伍?",handleOptionKick,null,true,null,JOptionPane.YES|JOptionPane.NO);
	}
	private function handleOptionKick(button:uint):void
	{
		if(button == JOptionPane.YES)
		{
			if(FrameTeam.isShowTeamSoul())
				Client.getInstance().sendPacketLogic(215,[CharInfo.charId,int(_item.m_nCharId)]);
			else
				Client.getInstance().sendPacketLogic(208,[CharInfo.charId,int(_item.m_nCharId)]);
		}
	}
	private function onBtnChat(e:Event):void
	{
		FrameTeam.hide();
		FrameFriendChat.show({m_nCharId:_item.m_nCharId,m_szCharName:_item.m_szCharName,m_nLevel:_item.m_nLevel,m_nRace:_item.m_nRace,m_nGender:_item.m_nGender});
	}
	
	private function onBtnName(e:Event):void
	{
		if(_item == null)
			return;
		
		var obj:Object = new Object;
		obj.m_nCharId = int(_item.m_nCharId);
		obj.m_szCharName = _item.m_szCharName;
		obj.m_nLevel = int(_item.m_nLevel);
		obj.m_nRace = int(_item.m_nRace);
		obj.m_nGender = int(_item.m_nGender);
		
		var point:IntPoint = AsWingUtils.getStageMousePosition();
		FrameClickChar._objDest = obj;
		FrameClickChar._destCharId = int(obj.m_nCharId);
		FrameClickChar.show(FrameTeam._frame,point.x-FrameTeam._frame.x,point.y-FrameTeam._frame.y);
	}
	
	/*private function onRollOver(event:MouseEvent):void
	{
		var target:JPanel = event.target as JPanel;
		if(!(target.getBorder() is EmptyBorder))
			return;
		target.setBorder(new LineBorder(null,ASColor.GREEN));
	}
	
	private function onRollOut(event:MouseEvent):void
	{
		var target:JPanel = event.target as JPanel;
		target.setBorder(new EmptyBorder());
	}*/
	//private var _tooltip:ToolTipItemCSV = new ToolTipItemCSV(0);
	public function set item(val:Object):void
	{
		_item = val;
		//_tooltip.setTargetComponent(null);
		//panelHead.setBackgroundDecorator(null);
		labelRace.setText("");
		labelName.setText("");
		labelGender.setText("");
		btn_promote.setVisible(false);
		btn_kick.setVisible(false);
		btn_chat.setVisible(false);
		panelHead.setBackgroundDecorator(null);
		if(_item == null)
		{
			return;
		}
		if(!FrameTeam.isShowTeamSoul())
		{
			btn_promote.setVisible(FrameTeam.isTeamLeader() && _item.m_nCharId != CharInfo.charId);
			btn_kick.setVisible(FrameTeam.isTeamLeader() && _item.m_nCharId != CharInfo.charId);
			btn_chat.setVisible(_item.m_nCharId != CharInfo.charId);
		}
		else
		{
			btn_promote.setVisible(false);
			btn_kick.setVisible(_item.m_nCharId != CharInfo.charId);
			btn_chat.setVisible(_item.m_nCharId != CharInfo.charId);
		}
		
		if(_item.m_nGender == 0)
			labelName.setForeground(new ASColor(Engine.colorBoy));
		if(_item.m_nGender == 1)
			labelName.setForeground(new ASColor(Engine.colorGirl));
		
		labelName.setText(_item.m_szCharName+' Lv.'+_item.m_nLevel);
		labelRace.setText('种族:' + (int(_item.m_nRace) == 0 ? '人':((_item.m_nRace) == 1 ?'魔':'仙')));
		labelGender.setText('性别:' + (int(_item.m_nGender) == 0 ? '男':'女'));
		panelHead.setBackgroundDecorator(new AssetBackground(Client.getUIElement("img_head") as DisplayObject));
	}
	
	public function get item():Object
	{
		return _item;
	}
	
	public function clear():void
	{
		setBackgroundDecorator(null);
		item = null;
	}
	//_________getters_________
	
	
}

/**
 * MyPaneTeamMain
 */
class FrameTeamMain extends JFrame
{
	
	//members define
	private var panelTeamMember0:PaneTeamMainMember;
	private var panelTeamMember1:PaneTeamMainMember;
	private var panelTeamMember2:PaneTeamMainMember;
	
	/**
	 * MyPaneTeamMain Constructor
	 */
	private var _mallItems:Array = new Array();
	public function FrameTeamMain(){
		
		//component creation
		//super();
		setDragable(false);
		setClosable(false);
		setResizable(false);
		//setBackgroundDecorator(null);
		//setBorder(new EmptyBorder());
		//getTitleBar().setMinimizeHeight(0);
		setTitleBar(null);
		setBorder(new EmptyBorder());
		this.setBackgroundDecorator(new SolidBackground(new ASColor(0,0)));
		
		//component creation
		setSize(new IntDimension(222, 70));
		setPreferredSize(new IntDimension(222, 70));
		var layout0:GridLayout = new GridLayout();
		layout0.setRows(1);
		layout0.setColumns(3);
		layout0.setHgap(6);
		layout0.setVgap(0);
		this.getContentPane().setLayout(layout0);
		
		panelTeamMember0 = new PaneTeamMainMember();
		panelTeamMember0.setSize(new IntDimension(222, 70));
		
		panelTeamMember1 = new PaneTeamMainMember();
		panelTeamMember1.setLocation(new IntPoint(114, 0));
		panelTeamMember1.setSize(new IntDimension(108, 70));
		
		panelTeamMember2 = new PaneTeamMainMember();
		panelTeamMember2.setLocation(new IntPoint(152, 0));
		panelTeamMember2.setSize(new IntDimension(70, 70));
		
		//component layoution
		getContentPane().append(panelTeamMember0);
		getContentPane().append(panelTeamMember1);
		getContentPane().append(panelTeamMember2);
		
		
		//---------------------
		
		_mallItems.push(panelTeamMember0);
		_mallItems.push(panelTeamMember1);
		_mallItems.push(panelTeamMember2);
		this.setClipMasked(false);
		getContentPane().setClipMasked(false);
	}
	
	public static var _frame:FrameTeamMain = null;
	public static function show():void
	{
		
		if(isShowing())
		{
			//hide()
			return;
		}
		if(_frame == null)
		{
			_frame = new FrameTeamMain();
			PanelMainHelp.getInstance().addChild(_frame);
		}
		_frame.show();
		PanelMainHelp.getInstance().bringToTop(_frame);
		_frame.setLocationXY(371,0);
		_frame.setEnabled(true);
		
	}
	public static function hide():void
	{
		if(isShowing())
		{
			_frame.hide();
			_frame.setEnabled(false);
		}
	}
	public static function isShowing():Boolean
	{
		return(_frame != null&& _frame.isShowing());
	}
	public function update():void
	{
		for each(var obj:Object in _mallItems)
		{
			obj.item = null;
		}
		//this.alpha = 1.0;
		//if(!FrameTeam.isInTeam())
		//	return;
		var nIndex:int = 0;
		var nCount:int = 0;
		var array:Array = null
		this.filters = null;

		if(CharInfo.objSelf == null)
			return;
		if(CharInfo.m_nUseTeamSoul == 0)
		{
			if(!FrameTeam.isInTeam())
				return;
			var objLeader:ObjectChar = SceneMain.getInstance().getObjectByCharId(CharInfo.objSelf.teamLeader.m_nCharId) as ObjectChar;
			if(objLeader == null)
			{
				trace("objLeader == null");
				return;
			}
			array = objLeader.teamMembers;
		}
		else
		{
			array = CharInfo.m_arTeamSoulMembers;
			//this.alpha = 0.7;
			var matrix : Array = [0.3086, 0.6094, 0.0820, 0, 0, 0.3086, 0.6094, 0.0820, 0, 0, 0.3086, 0.6094, 0.0820, 0, 0, 0, 0, 0, 1, 0];
			this.filters = [new ColorMatrixFilter(matrix)];
			//SceneMain.getInstance().filters = [new ColorMatrixFilter(matrix)];
			

		}
		
		//var objLeader:ObjectChar = SceneMain.getInstance().getObjectByCharId(CharInfo.objSelf.teamLeader.m_nCharId) as ObjectChar;
		//if(objLeader == null)
		//{
		//	trace("objLeader == null");
		//	return;
		//}
		for each(var item:Object in array)
		{
			_mallItems[nIndex++].item = item;
			if(nIndex >= 3)
				break;
		}
	}
	//_________getters_________	
}

/**
 * MyPaneTeamMember
 */
class PaneTeamMainMember extends JPanel{
	
	/**
	 * MyPaneTeamMember Constructor
	 */
	private var _item:Object = null;
	//members define
	public var panelImage:JPanel;
	public function PaneTeamMainMember(){
		//component creation
		//component creation
		setSize(new IntDimension(70, 70));
		setPreferredSize(new IntDimension(70, 70));
		
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		panelImage = new JPanel();
		panelImage.setLocation(new IntPoint(0, 0));
		panelImage.setSize(new IntDimension(68, 68));
		
		//component layoution
		append(panelImage);
		
		img_team_member_bg = new AssetBackground(Client.getUIElement("img_team_member_bg") as DisplayObject);
		img_head = new AssetBackground(Client.getUIElement("img_head") as DisplayObject);
		panelImage.addEventListener(MouseEvent.ROLL_OVER,onRollOver);
		panelImage.addEventListener(MouseEvent.ROLL_OUT,onRollOut);
		panelImage.addEventListener(MouseEvent.CLICK,onClick);
		setClipMasked(false);
		panelImage.setClipMasked(false);
		panelImage.buttonMode = true;
	}
	
	private var img_head:AssetBackground = null;
	private var img_team_member_bg:AssetBackground = null;
	
	private var _arrayFilters:Array = new Array(new GlowFilter(0xffff00, 1, 20, 20));
	private function onRollOver(event:MouseEvent):void
	{
		if(event.target.filters != _arrayFilters)
			event.target.filters = _arrayFilters;
	}
	
	private function onRollOut(event:MouseEvent):void
	{
		event.target.filters = null;
	}
	private function onClick(event:MouseEvent):void
	{
		if(!FrameTeam.isShowing())
			FrameTeam.show();
	}
	//private var _tooltip:ToolTipItemCSV = new ToolTipItemCSV(0);
	public function set item(val:Object):void
	{
		_item = val;
		panelImage.setBackgroundDecorator(null);
		setBackgroundDecorator(null);
		setToolTipText("");
		setEnabled(false);
		panelImage.setEnabled(false);
		if(_item == null)
		{
			return;
		}
		
		this.setToolTipText(_item.m_szCharName+' Lv.'+_item.m_nLevel+'\n'+'种族:' + (int(_item.m_nRace) == 0 ? '人':((_item.m_nRace) == 1 ?'魔':'仙'))+'\n'+'性别:' + (int(_item.m_nGender) == 0 ? '男':'女'));
		panelImage.setBackgroundDecorator(img_head);
		setBackgroundDecorator(img_team_member_bg);
		setEnabled(true);
		panelImage.setEnabled(true);
		this.paintImmediately();
	}
	public function get item():Object
	{
		return _item;
	}
	
	public function clear():void
	{
		panelImage.setBackgroundDecorator(null);
		setBackgroundDecorator(null);
		item = null;
	}
	//_________getters_________
	
	
}

import org.aswing.*;
import org.aswing.border.*;
import org.aswing.geom.*;
import org.aswing.colorchooser.*;
import org.aswing.ext.*;

/**
 * MyPaneTeamList
 */
class FrameTeamList extends JFrame{
	
	//members define
	private var panelTop:JPanel;
	private var panelTabs:JPanel;
	private var btn_tab_invite:JToggleButton;
	private var btn_tab_wait:JToggleButton;
	private var btn_tab_join_team_soul:JToggleButton;
	private var panelItems:JPanel;
	private var panel86:JPanel;
	private var btnPrev:JButton;
	private var labelPage:JLabel;
	private var btnNext:JButton;
	private var panel97:JPanel;
	private var btn_clearup:JButton;
	
	/**
	 * MyPaneTeamList Constructor
	 */
	//-----------------------------------
	private var btn_close:JButton;
	public function FrameTeamList(){
		//component creation
		//super();
		setResizable(false);
		setBackgroundDecorator(null);
		setBorder(new EmptyBorder());
		
		btn_close = new JButton();
		btn_close.setLocation(new IntPoint(198, -5));
		btn_close.setSize(new IntDimension(27, 27));
		btn_close.setPreferredSize(new IntDimension(27, 27));
		getTitleBar().setCloseButton(btn_close);
		getTitleBar().setMinimizeHeight(32);
		
		//component creation
		setSize(new IntDimension(278, 287));
		setPreferredSize(new IntDimension(278, 287));
		var layout0:EmptyLayout = new EmptyLayout();
		getContentPane().setLayout(layout0);
		
		panelTop = new JPanel();
		panelTop.setLocation(new IntPoint(0, 0));
		panelTop.setSize(new IntDimension(278, 33));
		panelTop.setPreferredSize(new IntDimension(278, 33));
		var layout1:FlowLayout = new FlowLayout();
		layout1.setAlignment(AsWingConstants.LEFT);
		layout1.setHgap(20);
		layout1.setVgap(4);
		layout1.setMargin(true);
		panelTop.setLayout(layout1);
		
		panelTabs = new JPanel();
		panelTabs.setLocation(new IntPoint(20, 4));
		panelTabs.setSize(new IntDimension(209, 23));
		var layout2:FlowWrapLayout = new FlowWrapLayout();
		layout2.setPreferWidth(200);
		layout2.setAlignment(AsWingConstants.LEFT);
		layout2.setHgap(3);
		layout2.setVgap(0);
		layout2.setMargin(false);
		panelTabs.setLayout(layout2);
		
		btn_tab_invite = new JToggleButton();
		btn_tab_invite.setLocation(new IntPoint(5, 5));
		btn_tab_invite.setSize(new IntDimension(59, 23));
		btn_tab_invite.setPreferredSize(new IntDimension(59, 23));
		btn_tab_invite.setText("label");
		
		btn_tab_wait = new JToggleButton();
		btn_tab_wait.setLocation(new IntPoint(59, 1));
		btn_tab_wait.setSize(new IntDimension(72, 23));
		btn_tab_wait.setPreferredSize(new IntDimension(72, 23));
		btn_tab_wait.setText("label");
		
		btn_tab_join_team_soul = new JToggleButton();
		btn_tab_join_team_soul.setLocation(new IntPoint(0, 25));
		btn_tab_join_team_soul.setSize(new IntDimension(72, 23));
		btn_tab_join_team_soul.setPreferredSize(new IntDimension(72, 23));
		btn_tab_join_team_soul.setText("label");
		
		panelItems = new JPanel();
		panelItems.setLocation(new IntPoint(11, 56));
		panelItems.setSize(new IntDimension(256, 138));
		panelItems.setPreferredSize(new IntDimension(256, 138));
		var layout3:GridLayout = new GridLayout();
		layout3.setRows(6);
		layout3.setColumns(1);
		layout3.setHgap(0);
		layout3.setVgap(0);
		panelItems.setLayout(layout3);
		
		panel86 = new JPanel();
		panel86.setLocation(new IntPoint(0, 200));
		panel86.setSize(new IntDimension(278, 24));
		panel86.setPreferredSize(new IntDimension(278, 24));
		var layout4:EmptyLayout = new EmptyLayout();
		panel86.setLayout(layout4);
		
		btnPrev = new JButton();
		btnPrev.setLocation(new IntPoint(83, 0));
		btnPrev.setSize(new IntDimension(29, 24));
		btnPrev.setPreferredSize(new IntDimension(29, 24));
		btnPrev.setText("label");
		
		labelPage = new JLabel();
		labelPage.setLocation(new IntPoint(122, 3));
		labelPage.setSize(new IntDimension(36, 16));
		labelPage.setPreferredSize(new IntDimension(36, 16));
		labelPage.setText("label");
		
		btnNext = new JButton();
		btnNext.setLocation(new IntPoint(168, 0));
		btnNext.setSize(new IntDimension(29, 24));
		btnNext.setPreferredSize(new IntDimension(29, 24));
		btnNext.setText("label");
		
		panel97 = new JPanel();
		panel97.setLocation(new IntPoint(0, 240));
		panel97.setSize(new IntDimension(278, 27));
		panel97.setPreferredSize(new IntDimension(278, 27));
		var layout5:CenterLayout = new CenterLayout();
		panel97.setLayout(layout5);
		
		btn_clearup = new JButton();
		btn_clearup.setLocation(new IntPoint(5, 5));
		btn_clearup.setSize(new IntDimension(79, 27));
		btn_clearup.setPreferredSize(new IntDimension(79, 27));
		btn_clearup.setText("label");
		
		//component layoution
		getContentPane().append(panelTop);
		getContentPane().append(panelItems);
		getContentPane().append(panel86);
		getContentPane().append(panel97);
		
		panelTop.append(panelTabs);
		
		panelTabs.append(btn_tab_invite);
		panelTabs.append(btn_tab_wait);
		panelTabs.append(btn_tab_join_team_soul);
		
		panel86.append(btnPrev);
		panel86.append(labelPage);
		panel86.append(btnNext);
		
		panel97.append(btn_clearup);
		
		//------------------------------
		setImages();
		addEventListener(FrameEvent.FRAME_CLOSING,onFrameClosing);
		addEventListener(AWEvent.HIDDEN,onFrameClosing);
		
		btn_tab_invite.addActionListener(onBtnInvite);
		btn_tab_wait.addActionListener(onBtnWait);
		btn_tab_join_team_soul.addActionListener(onBtnJoinTeamSoul);
		btn_clearup.addActionListener(onBtnClearup);
		setClipMasked(false);
		getContentPane().setClipMasked(false);
	}
	private function onFrameClosing(e:Event):void
	{
		//_frame.setLocationXY((Engine.W - _frame.width)/2,(Engine.H - _frame.height)/2);
		
		var teamDestX:int = (Engine.W - FrameTeam._frame.width)/2;
		var teamDestY:int = (Engine.H - FrameTeam._frame.height)/2;
		var tween:TweenLite = TweenLite.to(FrameTeam._frame, 0.3, {x:teamDestX, y:teamDestY});

	}
	private function onBtnClearup(e:Event):void
	{
		Client.getInstance().sendPacketLogic(211,[0]);
		_arWait.splice(0,_arWait.length);
		update();
	}
	private function onBtnInvite(e:Event):void
	{
		_frame.updatePage();
	}
	private function onBtnWait(e:Event):void
	{
		_frame.updatePage();
	}
	private function onBtnJoinTeamSoul(e:Event):void
	{
		_frame.updatePage();
	}
	private var _mallItems:Array = new Array();
	public function setImages():void
	{
		var img_char_background:DisplayObject = Client.getUIElement("img_list_bg") as DisplayObject
		setBackgroundDecorator(new AssetBackground(img_char_background));
		setSizeWH(img_char_background.width,img_char_background.height);
		setLocationXY((Engine.W - width)/2,(Engine.H - height)/2);
		btn_tab_invite.setSelected(true);
		
		
		btn_tab_invite.wrapSimpleButton(Client.getUIElement("btn_3") as SimpleButton);
		btn_tab_wait.wrapSimpleButton(Client.getUIElement("btn_4") as SimpleButton);
		btn_tab_join_team_soul.wrapSimpleButton(Client.getUIElement("btn_4") as SimpleButton);
		btn_tab_invite.setText("可邀请");
		btn_tab_wait.setText("等待入队");
		btn_tab_join_team_soul.setText("自己参与");
		
		btn_tab_invite.setHorizontalTextPosition(AsWingConstants.CENTER);
		btn_tab_invite.setVerticalTextPosition(AsWingConstants.CENTER);
		btn_tab_wait.setHorizontalTextPosition(AsWingConstants.CENTER);
		btn_tab_wait.setVerticalTextPosition(AsWingConstants.CENTER);
		btn_tab_join_team_soul.setHorizontalTextPosition(AsWingConstants.CENTER);
		btn_tab_join_team_soul.setVerticalTextPosition(AsWingConstants.CENTER);
		
		var group:ButtonGroup = new ButtonGroup();
		group.appendAll(btn_tab_invite,btn_tab_wait,btn_tab_join_team_soul);
		//btn_tab_invite.addActionListener(onBtnTabTeam);
		//btn_tab_wait.addActionListener(onBtnTabTeamSoul);
		
		btn_clearup.wrapSimpleButton(Client.getUIElement("btn_list_clearup") as SimpleButton);
		btn_clearup.setText("");
		
		btn_close.wrapSimpleButton(Client.getUIElement("btn_close") as SimpleButton);
		
		btnPrev.setText("");
		btnNext.setText("");
		
		btnPrev.wrapSimpleButton(Client.getUIElement("btn_prev") as SimpleButton);
		btnNext.wrapSimpleButton(Client.getUIElement("btn_next") as SimpleButton);
		
		btnPrev.addActionListener(onBtnPrev);
		btnNext.addActionListener(onBtnNext);
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 12, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 5);
		labelPage.setForeground(ASColor.WHITE);
		labelPage.setFont(font);
		labelPage.setTextFilters(new Array(filter));
		
		

		font = new ASFont("宋体", 13, false, false, false, false);

		btn_tab_invite.setFont(font);
		btn_tab_wait.setFont(font);
		btn_tab_join_team_soul.setFont(font);
		btn_tab_invite.setTextFilters(new Array(filter));
		btn_tab_wait.setTextFilters(new Array(filter));
		btn_tab_join_team_soul.setTextFilters(new Array(filter));
		
		for(var i:int = 0; i < _itemsPerPage; i++)
		{
			var item:PaneTeamListItem = new PaneTeamListItem;
			panelItems.append(item);
			_mallItems.push(item);
		}
		
		//_mallItems.push(panelMember_0);
		//_mallItems.push(panelMember_1);
		//_mallItems.push(panelMember_2);
	}
	public function isInviteMode():Boolean
	{
		return btn_tab_invite.isSelected();
	}
	public function isWaitMode():Boolean
	{
		return btn_tab_wait.isSelected();
	}
	public function isJoinTeamSoulMode():Boolean
	{
		return btn_tab_join_team_soul.isSelected();
	}
	private var _currentPageIndex:int = 0;
	private var _currentPageIndexAll:int = 0;
	private var _itemsPerPage:int = 6;
	public function updatePage():void
	{
		var objects:Array = null
		
		if(btn_tab_invite.isSelected())
			objects = _arInvite;
		if(btn_tab_wait.isSelected())
			objects = _arWait;
		if(btn_tab_join_team_soul.isSelected())
			objects = CharInfo.m_arJoinTeamSoul;
		
		for each(var obj:Object in _mallItems)
		{
			obj.item = null;
		}
		var nIndex:int = 0;
		var nCount:int = 0;
		for each(var item:Object in objects)
		{
			nCount++;
			if(nCount <= _currentPageIndex*_itemsPerPage)
				continue;
			_mallItems[nIndex++].item = item;
			if(nIndex >= _itemsPerPage)
				break;
		}
		
		var nCount1:int = objects.length;
		_currentPageIndexAll = Math.floor((nCount1+_itemsPerPage-1)/_itemsPerPage);
		labelPage.setText(_currentPageIndex+1+'/'+_currentPageIndexAll);
		btnPrev.setEnabled(_currentPageIndex > 0 &&  _currentPageIndexAll > 1);
		btnNext.setEnabled(_currentPageIndex < _currentPageIndexAll-1 &&  _currentPageIndexAll > 1);
		
		btn_clearup.setEnabled(!isInviteMode() && _arWait.length > 0);
	}
	
	private function onBtnPrev(event:Event):void
	{
		_currentPageIndex--;
		if(_currentPageIndex < 0)
			_currentPageIndex = 0;
		else
			updatePage();
		labelPage.setText(_currentPageIndex+1+'/'+_currentPageIndexAll);
	}
	private function onBtnNext(event:Event):void
	{
		_currentPageIndex++;
		if(_currentPageIndex > _currentPageIndexAll-1)
			_currentPageIndex = _currentPageIndexAll-1;
		else
			updatePage();
		labelPage.setText(_currentPageIndex+1+'/'+_currentPageIndexAll);
	}
	
	public static var _frame:FrameTeamList = null;
	public static function show():void
	{
		
		if(isShowing())
		{
			hide()
			return;
		}
		if(_frame == null)
		{
			_frame = new FrameTeamList();
			PanelMainHelp.getInstance().addChild(_frame);
		}
		_frame.show();
		PanelMainHelp.getInstance().bringToTop(_frame);
		
		_frame.setLocationXY((Engine.W - _frame.width)/2,(Engine.H - _frame.height)/2);
		
		var teamDestX:int = (Engine.W - (_frame.width+FrameTeam._frame.width))/2;
		var teamDestY:int = (Engine.H - FrameTeam._frame.height)/2;
		
		var listDestX:int = teamDestX + FrameTeam._frame.width;
		var listDestY:int = teamDestY + (FrameTeam._frame.height - _frame.height)/2;
		
		var tween:TweenLite = TweenLite.to(FrameTeam._frame, 0.3, {x:teamDestX, y:teamDestY});
		var list_tween:TweenLite = TweenLite.to(_frame, 0.3, {x:listDestX, y:listDestY});
		
		update();
	}
	static public var _arInvite:Array = new Array;
	static public var _arWait:Array = new Array;
	
	public static function hide():void
	{
		if(isShowing())_frame.hide();
	}
	public static function isShowing():Boolean
	{
		return(_frame != null&& _frame.isShowing());
	}
	
	public static function update():void
	{
		_frame.filters = null;
		//_frame.alpha = 1.0;
		_arInvite.splice(0,_arInvite.length);
		if(FrameTeam.isShowTeamSoul())
		{
			for each(var item:Object in CharInfo.m_arFriends)
			{
				if(FrameTeam.hasTeamSoulMember(item.m_nCharId))
					continue;
				if(item.m_nCharId != CharInfo.charId)
					_arInvite.push({m_nCharId:item.m_nCharId,m_szCharName:item.m_szCharName,m_nLevel:item.m_nLevel,m_nRace:item.m_nRace,m_nGender:item.m_nGender});
			}
			_frame.btn_tab_wait.setVisible(false);
			_frame.btn_tab_join_team_soul.setVisible(true);
			if(_frame.btn_tab_wait.isSelected())
			{
				_frame.btn_tab_wait.setSelected(false);
				_frame.btn_tab_join_team_soul.setSelected(true);
			}
			//var matrix : Array = [0.3086, 0.6094, 0.0820, 0, 0, 0.3086, 0.6094, 0.0820, 0, 0, 0.3086, 0.6094, 0.0820, 0, 0, 0, 0, 0, 1, 0];
			//_frame.filters = [new ColorMatrixFilter(matrix)];
		}
		else
		{
			var arr:Array = SceneMain.getInstance().getAllObjects();
			for each(var obj:ObjectBase in arr)
			{
				if(obj is ObjectCharPlayer && !(obj is ObjectCharLover) && !(obj is ObjectCharSlave))
				{
					if(obj is ObjectCharSoul)
					{
						if((obj as ObjectCharSoul).isSoul)
							continue;
					}
					var player:ObjectCharPlayer = obj as ObjectCharPlayer;
					
					if(FrameTeam.hasTeamMember(player.charId))
						continue;
					if(player.charId != CharInfo.charId && !player.isInTeam())
						_arInvite.push(player.userObject);
						//_arInvite.push({m_nCharId:player.charId,m_szCharName:player.getName(),m_nLevel:player.getLevel(),m_nRace:player.m_nRace,m_nGender:player.m_nGender});
				}
			}
			_frame.btn_tab_wait.setVisible(true);
			_frame.btn_tab_join_team_soul.setVisible(false);
			if(_frame.btn_tab_join_team_soul.isSelected())
			{
				_frame.btn_tab_join_team_soul.setSelected(false);
				_frame.btn_tab_wait.setSelected(true);
			}
		}
		_frame.panelTabs.pack();
		_frame.updatePage();
	}
	
}

/**
 * MyPaneTeamListItem
 */
class PaneTeamListItem extends JPanel{
	
	//members define
	private var labelName:JLabelButton;
	private var labelRace:JLabel;
	private var labelGender:JLabel;
	private var btn_agree:JButton;
	private var btn_invite:JButton;
	private var btn_leave:JButton;
	
	/**
	 * MyPaneTeamListItem Constructor
	 */
	public function PaneTeamListItem(){
		//component creation
		setSize(new IntDimension(256, 23));
		setPreferredSize(new IntDimension(256, 23));
		var layout0:EmptyLayout = new EmptyLayout();
		setLayout(layout0);
		
		labelName = new JLabelButton();
		labelName.setLocation(new IntPoint(0, 4));
		labelName.setSize(new IntDimension(133, 16));
		labelName.setPreferredSize(new IntDimension(133, 16));
		labelName.setText("label");
		
		labelRace = new JLabel();
		labelRace.setLocation(new IntPoint(134, 4));
		labelRace.setSize(new IntDimension(36, 16));
		labelRace.setPreferredSize(new IntDimension(36, 16));
		labelRace.setText("label");
		
		labelGender = new JLabel();
		labelGender.setLocation(new IntPoint(171, 4));
		labelGender.setSize(new IntDimension(36, 16));
		labelGender.setPreferredSize(new IntDimension(36, 16));
		labelGender.setText("label");
		
		btn_agree = new JButton();
		btn_agree.setLocation(new IntPoint(207, 0));
		btn_agree.setSize(new IntDimension(49, 23));
		btn_agree.setPreferredSize(new IntDimension(49, 23));
		btn_agree.setText("label");
		
		btn_invite = new JButton();
		btn_invite.setLocation(new IntPoint(207, 0));
		btn_invite.setSize(new IntDimension(49, 23));
		btn_invite.setPreferredSize(new IntDimension(49, 23));
		btn_invite.setText("label");
		
		btn_leave = new JButton();
		btn_leave.setLocation(new IntPoint(207, 0));
		btn_leave.setSize(new IntDimension(49, 23));
		btn_leave.setPreferredSize(new IntDimension(49, 23));
		btn_leave.setText("label");
		
		//component layoution
		append(labelName);
		append(labelRace);
		append(labelGender);
		append(btn_agree);
		append(btn_invite);
		append(btn_leave);
		
		
		var filter:GlowFilter;
		var font:ASFont = new ASFont("宋体", 12, false, false, false, false);
		filter = new GlowFilter(0x000000, 1, 2, 2, 10);
		//labelName.setFont(font);
		//labelName.setForeground(ASColor.WHITE);
		//labelName.setTextFilters(new Array(filter));
		labelRace.setFont(font);
		labelRace.setForeground(ASColor.WHITE);
		labelRace.setTextFilters(new Array(filter));
		labelGender.setFont(font);
		labelGender.setForeground(ASColor.WHITE);
		labelGender.setTextFilters(new Array(filter));
		
		btn_agree.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
		btn_agree.setText("同意");
		btn_invite.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
		btn_invite.setText("邀请");
		btn_leave.wrapSimpleButton(Client.getUIElement("btn_2") as SimpleButton);
		btn_leave.setText("离队");
		
		btn_agree.addActionListener(onBtnAgree);
		btn_invite.addActionListener(onBtnInvite);
		btn_leave.addActionListener(onBtnLeave);
		
		labelName.setForeground(ASColor.WHITE);
		labelName.setFont(new ASFont("宋体", 12, false, false, true, false));
		labelName.setTextFilters( new Array(filter));
		labelName.addActionListener(onBtnName);
		
		font = new ASFont("宋体", 13, false, false, false, false);
		btn_agree.setFont(font);
		btn_agree.setTextFilters(new Array(filter));
		btn_invite.setFont(font);
		btn_invite.setTextFilters(new Array(filter));
		btn_leave.setFont(font);
		btn_leave.setTextFilters(new Array(filter));
		
		setClipMasked(false);
	}
	private var _item:Object = null;
	public function set item(val:Object):void
	{
		_item = val;
		labelRace.setText("");
		labelName.setText("");
		labelGender.setText("");

		btn_invite.setVisible(false);
		btn_agree.setVisible(false);
		btn_leave.setVisible(false);
		
		if(_item == null)
		{
			return;
		}
		if(FrameTeamList.isShowing())
		{
			btn_invite.setVisible(FrameTeamList._frame.isInviteMode());
			btn_agree.setVisible(FrameTeamList._frame.isWaitMode());
			btn_leave.setVisible(FrameTeamList._frame.isJoinTeamSoulMode());
		}
		
		if(_item.m_nGender == 0)
			labelName.setForeground(new ASColor(Engine.colorBoy));
		if(_item.m_nGender == 1)
			labelName.setForeground(new ASColor(Engine.colorGirl));
		
		labelName.setText(_item.m_szCharName+' Lv.'+_item.m_nLevel);
		labelRace.setText((int(_item.m_nRace) == 0 ? '人':((_item.m_nRace) == 1 ?'魔':'仙')));
		labelGender.setText((int(_item.m_nGender) == 0 ? '男':'女'));
	}
	
	private function onBtnName(e:Event):void
	{
		if(_item == null)
			return;
		
		var obj:Object = new Object;
		obj.m_nCharId = int(_item.m_nCharId);
		obj.m_szCharName = _item.strCharName;
		obj.m_nLevel = int(_item.m_nLevel);
		obj.m_nRace = int(_item.m_nRace);
		obj.m_nGender = int(_item.m_nGender);
		
		var point:IntPoint = AsWingUtils.getStageMousePosition();
		FrameClickChar._objDest = obj;
		FrameClickChar._destCharId = int(obj.m_nCharId);
		FrameClickChar.show(FrameTeamList._frame,point.x-FrameTeamList._frame.x,point.y-FrameTeamList._frame.y);
	}
	
	private function onBtnInvite(e:Event):void
	{
		if(FrameTeam.isShowTeamSoul())
			Client.getInstance().sendPacketLogic(212,[_item.m_nCharId]);
		else
			Client.getInstance().sendPacketLogic(200,[_item.m_nCharId]);
	}
	private function onBtnAgree(e:Event):void
	{
		Client.getInstance().sendPacketLogic(201,[0,_item.m_nCharId,_item.m_szCharName]);
	}
	
	private function onBtnLeave(e:Event):void
	{
		//Client.getInstance().sendPacketLogic(219,[_item.m_nCharId]);
		FrameInfo.showMessageDialog("","是否离开  "+_item.m_szCharName+" 的元神队伍?",handleOptionLeave,null,true,null,JOptionPane.YES|JOptionPane.NO);
	}
	private function handleOptionLeave(button:uint):void
	{
		if(button == JOptionPane.YES)
		{
			Client.getInstance().sendPacketLogic(219,[_item.m_nCharId]);
		}
	}
	public function get item():Object
	{
		return _item;
	}
	
}